package json;

/**
 * Created by Yang Fan on 2017/12/15.
 */

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class TaskJson{



    String modelId;
    String xmlDirectory;
    String toFile;
    String uuid;

    List<String> modelIds=new ArrayList<>();

    @JsonCreator
    public TaskJson(
            @JsonProperty("modelId") String modelId,
            @JsonProperty("xmlDirectory") String xmlDirectory,
            @JsonProperty("toFile") String toFile,
            @JsonProperty("uuid") String uuid
            ) {
        this.modelId = modelId;
        if(!this.modelId.trim().equals("")){

            String [] ids = this.modelId.trim().split(",");
            for (String id:ids){
                this.modelIds.add(id.trim());

            }
        }
        this.xmlDirectory=xmlDirectory;
        this.uuid=uuid;
        this.toFile=toFile;
    }

    boolean state=false;
    public String getToFile() {
        return toFile;
    }
    public String getXmlDirectory() {
        return xmlDirectory;
    }
    public String getUuid() {
        return uuid;
    }
    public String getModelId(){return  modelId;}


//    public static void main(String[] args) throws Exception {
//
//        try {
//            String str = "{\n" +
//                    "  \"modelId\":\"2016111129385732924\",\n" +
//                    "  \"xmlDirectory \":\"/home/xml/renwuA/\",\n" +
//                    "  \"toFile \":\"/home/result/result.txt\",\n" +
//                    "  \"uuid\":\"be0f3908-ff44-4688-a8e2-6d445c16c0b5\"\n" +
//                    "}\n";
//            ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//            TaskJson injson = objectMapper.readValue(str, TaskJson.class);
//
//            if(!injson.getModelId().trim().equals("1"))
//                return;
//
//        }catch (IOException e){
//            e.printStackTrace();
//        }
//        finally {
//            System.out.println("exec!");
//        }
//
//    }
//


}